Skip to content

Conversation

@liuxiaopai-ai
Copy link

Summary

Fixes #369

When launching a browser on Linux in --headed mode (e.g., via VNC or Xvfb), Playwright's launch() and launchPersistentContext() calls did not receive the parent process's environment variables. This caused the DISPLAY variable (and any other environment variables) to be missing in the browser subprocess, resulting in the error:

Missing X server or $DISPLAY

Root Cause

Playwright's launch() accepts an env option. When omitted, Playwright uses process.env by default in most cases, but in certain deployment scenarios (Docker, VNC, Xvfb), the environment is not correctly inherited by the browser subprocess. Explicitly passing env: { ...process.env } ensures all environment variables—including DISPLAY—are forwarded reliably.

Changes

Added env: { ...process.env } to all three browser launch calls in src/browser.ts:

  1. launcher.launchPersistentContext() — extensions path
  2. launcher.launchPersistentContext() — profile path
  3. launcher.launch() — regular ephemeral browser

Impact

This fix affects Linux users running agent-browser in headed mode, particularly in:

  • VNC sessions
  • Xvfb virtual display environments
  • Docker containers with X11 forwarding
  • Any setup where DISPLAY or other environment variables need to reach the browser process

@vercel
Copy link
Contributor

vercel bot commented Feb 7, 2026

Someone is attempting to deploy a commit to the Vercel Labs Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

--headed fails on Linux: DISPLAY env var not passed to browser subprocess

1 participant